package logik;

import gui.Screen;
import data.BankDatabase;
import data.User;

/**
 * @author Besitzer
 *
 */
public class Admin extends User {

	private boolean adminActive = true;
	private Screen screen;
	private BankDatabase db;
	
	public Admin(BankDatabase db, Screen screen, User user) {
		
		super(1234567, 7654321, "Mads", "Nyborg"); // Calls superclass constructor with hardcoded cpr and pin
		this.screen = screen;
		this.db = db;
		db.userList.add(this); // adds admin to the userlist
		this.isAdmin = true; // sets user to admin
		db.addUser(new User(12345, 54321, "Mads", "Nyborg"));
	}

	/* (non-Javadoc)
	 * @see logik.User#validatePIN(int)
	 * // Checks admin pin to create menu
	 */
	@Override
	public final boolean validatePIN(int userPIN){
		if (userPIN == this.getPin()){
			initAdmin();
			return true;
		} // end if
		else {
			return false;
		} // end else
	} // end method
	
	public boolean getAdmin(){
		return adminActive;
	}
	
	/**
	 * @category Initializes the admin menu
	 */
	public final void initAdmin() {
//		
		if (answer == 1) {
			db.createUser(); // if 1 chosen : runs user creation
			initAdmin();
		}
		else if (answer == 2) { 
			db.deleteUser(); // if 2 chosen : runs user deletion
			initAdmin();
		}
		else if (answer == 3) {
			db.displayAccount();
			initAdmin();			
		}
		else if (answer == 4) {
			adminActive = false; // if 3 chosen : exit administrator panel
		}
		else {
			initAdmin();
		}
		
		
	}

}